#define _CRT_SECURE_NO_WARNINGS 1

struct ListNode* removeNthFromEnd(struct ListNode* head, int n) {
    struct ListNode* fast = head;
    struct ListNode* slow = head;
    struct ListNode* poi = NULL;
    int i = 0;
    while (i < n)
    {
        fast = fast->next;
        i++;
    }
    while (fast)
    {
        fast = fast->next;
        poi = slow;
        slow = slow->next;
    }
    if (poi == NULL)
    {
        head = head->next;
        fast = NULL;
        return head;
    }
    poi->next = slow->next;
    free(fast);
    return head;
}